
def my_middleware(get_response):
    """初始化django时被调用"""
    print('初始化django时被调用')
    def middleware(request):
        """处理视图前被调用"""
        print('处理视图前被调用')
        response = get_response(request)
        """处理视图后被调用"""
        print('处理视图后被调用')
        return response
    return middleware